import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;


//比较器
//class IntCmp implements Comparator<Integer> {
//    @Override
//    public int compare(Integer o1, Integer o2) {
//        return o2-o1;
//    }
//}
public class topK {

    public static void main(String[] args) {
        //数据用例
        int[]arr={10,5,6,2,174,80,6,8};
        Scanner scanner=new Scanner(System.in);
        //输入要查询前K项
        int k=scanner.nextInt();
        PriorityQueue<Integer> p = new PriorityQueue<>();
        //将数据用例创建为大根堆
        for (int i = 0; i < arr.length; i++) {
            p.offer(arr[i]);
        }
        //弹出小根堆前K项元素，即为要查找的前K项最小元素
        for (int j = 0; j < k; j++) {
            System.out.print(p.poll()+" ");
        }
    }
}
